home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: [Q] Help. Initializing crashes program!!!
- Date: 28 Feb 1996 13:06:02 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h2g3qINN1kk@anvil.ugrad.cs.ubc.ca>
- References: <1996Feb28.084428.1@debbie.ee.queensu.ca>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <1996Feb28.084428.1@debbie.ee.queensu.ca>,
- <majeed@qucdntri.ee.queensu.ca> wrote:
- >Hello.
- >
- >Alright, here's are some definitions:
- >
- >#define N 8
- >#define L 13
- >
- >typedef struct
- >{
- > float I[L],Q[L];
- >} f_short_array;
- >
- >Here's a subroutine:
- >void PROC1(void)
- >{
- > int m,j;
- > ... (other declarations)
- > static f_short_array poly_reg[N];
- >
- >/* initializing */
- > for (m = 0; m < N; m++)
- > {
- > for (j = 0; j < L; j++)
- > {
- > poly_reg[m].I[j] = 0.0;
- > poly_reg[m].Q[j] = 0.0;
- > }
- > }
-
- [ snip ]
-
- >Why is it that if I leave the initialization as above, the program crashes
-
- The initialization should have no effect, since the struct array is static, and
- static floats will be initialized to 0.0 if they don't have explicit
- initializers.
-
- The only effect of including the initialization code as opposed to not
- including it is that after the loops, the variable m contains N, and j contains
- L.
-
- Does the subsequent code depend on the values of m or j? Does any of the code
- access past the array bounds or invoke any other sort of undefined behavior?
-
- If not, your compiler or linker is broken.
- --
-
-